﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using Public;

namespace WebsiteAdmin.Salomon.AdInfo
{
    public partial class AdHeadEdit : System.Web.UI.Page
    {
        public int pkid;
        public int adType;
        public string adTitle;
        public int catID;
        public string imgURL;
        public string keywords;
        public string description;
        public string adContent;
        public string startDate;
        public string endDate;
        public int strCatID = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pkid = Convert.ToInt32(Request["pkid"], CultureInfo.InvariantCulture);
                DataTable dtAD = Bll.CategoryAd.Single(Global.ConSalomon, pkid);
                if (dtAD.Rows.Count == 1)
                {
                    adType = Convert.ToInt16(dtAD.Rows[0]["AdType"]);
                    adTitle = dtAD.Rows[0]["AdTitle"].ToString();
                    catID = Convert.ToInt32(dtAD.Rows[0]["CatID"]);
                    imgURL = dtAD.Rows[0]["ImgURL"].ToString();
                    keywords = dtAD.Rows[0]["Keywords"].ToString();
                    description = dtAD.Rows[0]["Description"].ToString();
                    adContent = dtAD.Rows[0]["AdContent"].ToString();
                    startDate = Convert.ToDateTime(dtAD.Rows[0]["StartDate"]).ToString("yyyy-MM-dd");
                    endDate = Convert.ToDateTime(dtAD.Rows[0]["EndDate"]).ToString("yyyy-MM-dd");


                    DataTable dtCat = Bll.Category.MULTIPLE(Global.ConSalomon, strCatID);

                    if (dtCat.Rows.Count > 0)
                    {
                        RP_Cat.DataSource = dtCat.DefaultView;
                        RP_Cat.DataBind();
                    }

                    dtCat.Dispose();

                }



                dtAD.Dispose();


            }
        }
    }
}
